<template>
	<common-select
		v-model:data="state.data"
		:label="state.label"
		:value="state.value"
		:fields="state.columns"
		:tableData="state.table.data"
		:curPage="state.table.currentPage"
		:pageSize="state.table.pageSize"
		:total="state.table.total"
		:border="true"
		clearable
		editable
		@currentChange="currentChange"
		@sizeChange="sizeChange"
		@inputChange="inputChange"
		@blur="blurInput"
		@clear="clear"
		@handleRowClick="handleRowClick"
	></common-select>
</template>

<script setup lang="ts">
import { useBizSelect } from '../hooks/useBizSelect';
import CommonSelect from './commonSelect.vue';
import { fetchWarehouseList } from '/@/api/platform/wms/warehouse';

const model = defineModel();

const emit = defineEmits(['change']);
// 获取props中的参数
const props = defineProps({
  queryParams: {
    type: Object,
    default: () => {
    }
  },
  pageList: {
    type: Object,
    default: () => {
    }
  },
  value: {
    type: Object,
    default: () => {
    }
  },
  label: {
    type: Object,
    default: () => {
    }
  }
});

const { state, inputChange, blurInput, currentChange, sizeChange, clear, handleRowClick } = useBizSelect({
	model: model,
	pageList: props.pageList || fetchWarehouseList,
	label: props.label || 'warehouseCode',
	queryParams: props.queryParams || {},
	emit: emit,
	value: props.value || 'warehouseCode',
	columns: [
		{ label: '仓库代码', prop: 'warehouseCode', width: 200 },
		{ label: '仓库名称', prop: 'warehouseName', width: 200 }
	]
});
</script>

<style scoped></style>
